package com.qf.kdgroup.gdbackend.controller;

import com.github.pagehelper.PageInfo;
import com.qf.kdgroup.gdbackend.dto.ResultBean;
import com.qf.kdgroup.gdbackend.entity.Worksite;
import com.qf.kdgroup.gdbackend.service.WorksiteService;
import com.qf.kdgroup.gdbackend.vo.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/workSite")
@CrossOrigin
@Slf4j
public class WorksiteController {

    @Autowired
    private WorksiteService worksiteService;

    @PostMapping("/getList")
    public PageInfo getList(@RequestBody PageVO pageVO){

        return worksiteService.selectAllByPage(pageVO);

    }

    @DeleteMapping("/delete")
    public ResultBean deleteById(@RequestBody Worksite worksite){

        ResultBean resultBean = worksiteService.deleteById(worksite.getWid());

        return resultBean;
    }

    @PostMapping("/add")
    public ResultBean add(@RequestBody Worksite worksite){

        ResultBean resultBean = worksiteService.add(worksite);

        return resultBean;
    }

    @PostMapping("/find")
    public ResultBean findByWid(@RequestBody Worksite worksite){

        ResultBean resultBean = worksiteService.findByWid(worksite.getWid());

        return resultBean;
    }

    @PostMapping("/update")
    public ResultBean update(@RequestBody Worksite worksite){

        ResultBean resultBean = worksiteService.update(worksite);

        return resultBean;
    }
}
